<?php
/**
 * @ClassName: FreequeuingLogic
 * @Description: TODO
 * @author: gydtrade
 * @Date: 2025-11-12 16:34
 * @Version: V1.0.0
 */

namespace app\common\logic;

use app\common\model;

class FreequeuingLogic
{
    protected $trade_no;
    protected $orderInfo;
    protected $storeInfo;
    protected $order_goods;
    protected $goodsInfo;
    protected $ratio;
    protected $free_num;
    protected $queuing_num;

    function __construct($trade_no = '')
    {
        if ($trade_no) {
            $this->trade_no = $trade_no;
            $this->orderInfo = model\ShopOrder::where(['order_sn' => $trade_no])->find();
            $this->storeInfo = model\Store::where('id', $this->orderInfo['store_id'])->find();
            $this->order_goods = model\ShopOrderGoods::where('order_id', $this->orderInfo['id'])->find();
            $this->goodsInfo = model\ShopGoods::where('id', $this->order_goods['goods_id'])->find();
            $this->free_num = $this->goodsInfo['free_num'];//商品免单次数

            $sysConfig = web_config('free_queuing');
            $this->queuing_num = $sysConfig['queuing_num'];//会员排队次数
//            $this->ratio = bcdiv($sysConfig['free_amount_rate'], 100, 4);
            $this->ratio = bcdiv($this->goodsInfo['free_queuing_ratio'], 100, 4);
        }
    }

}